Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document debug logging. #5671

Merged
merged 1 commit into from
Dec 31, 2019
Merged

Document debug logging. #5671

merged 1 commit into from
Dec 31, 2019

Conversation

swankjesse
Copy link
Collaborator

Also refine the formatting of TaskRunner logging.

Before:

[2019-12-30 16:43:19] Q1 starting: OkHttp ConnectionPool
[2019-12-30 16:43:19] Q1 scheduled after 300 s: OkHttp ConnectionPool
[2019-12-30 16:43:19] Q1 finished in 94 µs: OkHttp ConnectionPool
[2019-12-30 16:43:19] Q359 scheduled after 0 µs: OkHttp www.youtube.com applyAndAckSettings
[2019-12-30 16:43:19] Q359 starting: OkHttp www.youtube.com applyAndAckSettings
[2019-12-30 16:43:19] Q361 schedule canceled (queue is shutdown): OkHttp www.youtube.com onSettings
[2019-12-30 16:43:19] Q359 finished in 382 µs: OkHttp www.youtube.com applyAndAckSettings
[2019-12-30 16:43:20] Q1 scheduled after 0 µs: OkHttp ConnectionPool
[2019-12-30 16:43:20] Q365 scheduled after 0 µs: OkHttp android-developers.googleblog.com applyAndAckSettings
[2019-12-30 16:43:20] Q1 starting: OkHttp ConnectionPool
[2019-12-30 16:43:20] Q365 starting: OkHttp android-developers.googleblog.com applyAndAckSettings
[2019-12-30 16:43:20] Q1 scheduled after 300 s: OkHttp ConnectionPool
[2019-12-30 16:43:20] Q1 finished in 151 µs: OkHttp ConnectionPool

After:

[2019-12-30 16:43:19] Q10001 starting              : OkHttp ConnectionPool
[2019-12-30 16:43:19] Q10001 run again after 300 s : OkHttp ConnectionPool
[2019-12-30 16:43:19] Q10001 finished run in  94 µs: OkHttp ConnectionPool
[2019-12-30 16:43:19] Q10359 scheduled after   0 µs: OkHttp www.youtube.com applyAndAckSettings
[2019-12-30 16:43:19] Q10359 starting              : OkHttp www.youtube.com applyAndAckSettings
[2019-12-30 16:43:19] Q10361 schedule canceled (queue is shutdown): OkHttp www.youtube.com onSettings
[2019-12-30 16:43:19] Q10359 finished run in 382 µs: OkHttp www.youtube.com applyAndAckSettings
[2019-12-30 16:43:20] Q10001 scheduled after   0 µs: OkHttp ConnectionPool
[2019-12-30 16:43:20] Q10365 scheduled after   0 µs: OkHttp android-developers.googleblog.com applyAndAckSettings
[2019-12-30 16:43:20] Q10001 starting              : OkHttp ConnectionPool
[2019-12-30 16:43:20] Q10365 starting              : OkHttp android-developers.googleblog.com applyAndAckSettings
[2019-12-30 16:43:20] Q10001 run again after 300 s : OkHttp ConnectionPool
[2019-12-30 16:43:20] Q10001 finished run in 151 µs: OkHttp ConnectionPool

} else {
log(task, queue, "failed in ${formatDuration(elapsedNs)}")
log(task, queue, "failed a run in ${formatDuration(elapsedNs)}")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

carefully chosen words to get the right width!

OkHttp has internal APIs to enable debug logging. It uses the `java.util.logging` API which can be
tricky to configure. As a shortcut, you can paste [OkHttpDebugLogging.kt]. Then enable debug logging
for whichever features you need:

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth a sentence on Android, example logcat filter etc?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added. Turns out hooking up logcat to java.util.Logging nicely is a bit of a pain if you want to use FINE!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Good idea though!)

@yschimke
Copy link
Collaborator

Nice user friendly change!

@swankjesse swankjesse force-pushed the jwilson.1230.debug_logging branch 2 times, most recently from 37d3663 to a2f0fe7 Compare December 31, 2019 18:39
Also refine the formatting of TaskRunner logging.

Before:

    [2019-12-30 16:43:19] Q1 starting: OkHttp ConnectionPool
    [2019-12-30 16:43:19] Q1 scheduled after 300 s: OkHttp ConnectionPool
    [2019-12-30 16:43:19] Q1 finished in 94 µs: OkHttp ConnectionPool
    [2019-12-30 16:43:19] Q359 scheduled after 0 µs: OkHttp www.youtube.com applyAndAckSettings
    [2019-12-30 16:43:19] Q359 starting: OkHttp www.youtube.com applyAndAckSettings
    [2019-12-30 16:43:19] Q361 schedule canceled (queue is shutdown): OkHttp www.youtube.com onSettings
    [2019-12-30 16:43:19] Q359 finished in 382 µs: OkHttp www.youtube.com applyAndAckSettings
    [2019-12-30 16:43:20] Q1 scheduled after 0 µs: OkHttp ConnectionPool
    [2019-12-30 16:43:20] Q365 scheduled after 0 µs: OkHttp android-developers.googleblog.com applyAndAckSettings
    [2019-12-30 16:43:20] Q1 starting: OkHttp ConnectionPool
    [2019-12-30 16:43:20] Q365 starting: OkHttp android-developers.googleblog.com applyAndAckSettings
    [2019-12-30 16:43:20] Q1 scheduled after 300 s: OkHttp ConnectionPool
    [2019-12-30 16:43:20] Q1 finished in 151 µs: OkHttp ConnectionPool

After:

    [2019-12-30 16:43:19] Q10001 starting              : OkHttp ConnectionPool
    [2019-12-30 16:43:19] Q10001 run again after 300 s : OkHttp ConnectionPool
    [2019-12-30 16:43:19] Q10001 finished run in  94 µs: OkHttp ConnectionPool
    [2019-12-30 16:43:19] Q10359 scheduled after   0 µs: OkHttp www.youtube.com applyAndAckSettings
    [2019-12-30 16:43:19] Q10359 starting              : OkHttp www.youtube.com applyAndAckSettings
    [2019-12-30 16:43:19] Q10361 schedule canceled (queue is shutdown): OkHttp www.youtube.com onSettings
    [2019-12-30 16:43:19] Q10359 finished run in 382 µs: OkHttp www.youtube.com applyAndAckSettings
    [2019-12-30 16:43:20] Q10001 scheduled after   0 µs: OkHttp ConnectionPool
    [2019-12-30 16:43:20] Q10365 scheduled after   0 µs: OkHttp android-developers.googleblog.com applyAndAckSettings
    [2019-12-30 16:43:20] Q10001 starting              : OkHttp ConnectionPool
    [2019-12-30 16:43:20] Q10365 starting              : OkHttp android-developers.googleblog.com applyAndAckSettings
    [2019-12-30 16:43:20] Q10001 run again after 300 s : OkHttp ConnectionPool
    [2019-12-30 16:43:20] Q10001 finished run in 151 µs: OkHttp ConnectionPool
@swankjesse swankjesse force-pushed the jwilson.1230.debug_logging branch from a2f0fe7 to a815093 Compare December 31, 2019 19:21
@swankjesse swankjesse merged commit bd675a8 into master Dec 31, 2019
@swankjesse swankjesse deleted the jwilson.1230.debug_logging branch January 1, 2020 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants